package com.fw.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fw.annotation.Log;
import com.fw.core.controller.BaseController;
import com.fw.core.domain.AjaxResult;
import com.fw.enums.BusinessType;
import com.fw.system.admin.domain.TbGunsLog;
import com.fw.system.admin.service.ITbGunsLogService;
import com.fw.utils.poi.ExcelUtil;
import com.fw.core.page.TableDataInfo;

/**
 * 装备购买出售记录Controller
 * 
 * @author xxx
 * @date 2021-12-03
 */
@RestController
@RequestMapping("/admin/guns_log")
public class TbGunsLogController extends BaseController
{
    @Autowired
    private ITbGunsLogService tbGunsLogService;

    /**
     * 查询装备购买出售记录列表
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_log:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbGunsLog tbGunsLog)
    {
        startPage();
        List<TbGunsLog> list = tbGunsLogService.selectTbGunsLogList(tbGunsLog);
        return getDataTable(list);
    }

    /**
     * 导出装备购买出售记录列表
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_log:export')")
    @Log(title = "装备购买出售记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbGunsLog tbGunsLog)
    {
        List<TbGunsLog> list = tbGunsLogService.selectTbGunsLogList(tbGunsLog);
        ExcelUtil<TbGunsLog> util = new ExcelUtil<TbGunsLog>(TbGunsLog.class);
        return util.exportExcel(list, "guns_log");
    }

    /**
     * 获取装备购买出售记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tbGunsLogService.selectTbGunsLogById(id));
    }

    /**
     * 新增装备购买出售记录
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_log:add')")
    @Log(title = "装备购买出售记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbGunsLog tbGunsLog)
    {
        return toAjax(tbGunsLogService.insertTbGunsLog(tbGunsLog));
    }

    /**
     * 修改装备购买出售记录
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_log:edit')")
    @Log(title = "装备购买出售记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbGunsLog tbGunsLog)
    {
        return toAjax(tbGunsLogService.updateTbGunsLog(tbGunsLog));
    }

    /**
     * 删除装备购买出售记录
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_log:remove')")
    @Log(title = "装备购买出售记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbGunsLogService.deleteTbGunsLogByIds(ids));
    }
}
